<template>
    <div>
        <div class="news">
            <el-table :data="newsList" border style="width: 100%">
                <el-table-column
                    prop="title"
                    label="名称"
                    align="center"
                ></el-table-column>
                <el-table-column label="上传时间" align="center">
                    <template slot-scope="scope">
                        <p>{{ scope.row.createTime | pattime }}</p>
                    </template>
                </el-table-column>
                <el-table-column label="操作" align="center">
                    <template slot-scope="scope">
                        <a
                            target="_blank"
                            :href="prefixUrl + scope.row.coverFileUrl"
                        >
                            <el-button type="danger" size="small"
                                >下载</el-button
                            >
                        </a>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <!-- <div class="news-page">
            <el-pagination
                background
                layout="prev, pager, next"
                :total="totalSum"
                :page-size="sizeSum"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
            ></el-pagination>
        </div> -->
    </div>
</template>

<script>
export default {
    data() {
        return {
            newsList: [],
            totalSum: 3,
            sizeSum: 10,
            prefixUrl: "",
        };
    },
    filters: {
        pattime(value) {
            return value.slice(0, 10);
        },
    },
    props: {
        tikuList: {
            type: Array,
        },
    },
    watch: {
        tikuList: {
            handler(val, oldVal) {
                console.log("--------");
                console.log(val);
                this.newsList = [...val];
            },
            deep: true,
        },
    },
    created() {
        this.prefixUrl = this.$store.state.user.imgUrl;
        // this.getIndustryInfo(1);
    },
    methods: {
        async getIndustryInfo(val) {
            var data = { currentPage: val, pageSize: 10, menuType: "2" };
            const res = await this.$store.dispatch("news/getTrainList", data);
            this.newsList = res.list;
            this.totalSum = res.totalCount;
            console.log(this.newsList);
        },
        // handleSizeChange(val) {
        //     console.log(`每页 ${val} 条`);
        // },
        // handleCurrentChange(val) {
        //     this.getIndustryInfo(val)
        // },
    },
};
</script>

<style scoped>
.news {
    padding: 20px 0;
}

.news-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
}

/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
    background: #c02636;
}
</style>
